import {http} from '@/utils/http'
import type {PageParams} from '@/utils/http/types'

const baseUrl = '/contract/borrowingRecord'

export const deleteBorrowingRecords = (ids: number[]) => {
  return http.delete(baseUrl, ids)
}

export const cReturn = (data: BorrowingRecord) => {
  return http.put(baseUrl, data)
}

export const getBorrowingRecord = (id: number) => {
  return http.get<Required<BorrowingRecord>>(`${baseUrl}/${id}`)
}

export const getBorrowingRecordByContractId = (id: number) => {
  return http.get<Required<BorrowingRecord>>(`${baseUrl}/byContractId/${id}`)
}

export const borrow = (data: BorrowingRecord) => {
  return http.post(baseUrl, data)
}

export const listBorrowingRecords = (pageParams?: PageParams, borrowingRecord?: Partial<BorrowingRecord>) => {
  return http.listPage<Required<BorrowingRecord>>(baseUrl, pageParams, borrowingRecord)
}
